home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / dev / misc / addtext.lha / Addtext / AddText.a < prev    next >
Encoding:
Text File  |  1996-02-25  |  88.6 KB  |  1,795 lines

  1.  
  2. *****************************************************************************
  3. * Project Details                                                           *
  4. * ---------------                                                           *
  5. * Project Name:    ADDTEXT                                                  *
  6. * Project Version: 1                                                        *
  7. * Copyright:       A N Peck                                                 *
  8. * Date:            Wednesday 22nd February 1995                             *
  9. *                                                                           *
  10. * Contact:                                                                  *
  11. * 68 Woralul ST                                                             *
  12. * Waramanga ACT 2611                                                        *
  13. * AUSTRALIA                                                                 *
  14. *                                                                           *
  15. * E-mail: Anthony.Peck@Radford.act.edu.au                                   *
  16. *                                                                           *
  17. *****************************************************************************
  18. *                                                                           *
  19. * File Summary:                                                             *
  20. * ------------                                                              *
  21. * Assembly version of Addtext                                               *
  22. *                                                                           *
  23. * Thanx to the following software and authors/publishers:                   *
  24. *                                                                           *
  25. * Phxass/Phxlnk - F.Wille                                                   *
  26. * EdWordPro - M. Reddy                                                      *
  27. * S-Text - C. Wyndham                                                       *
  28. * S-Exec - C. Wyndham                                                       *
  29. * Hextract - C. Wyndham                                                     *
  30. * Makeicon - R. Lang                                                        *
  31. * DevPac - HiSoft                                                           *
  32. * DPaint - Electronic Arts                                                  *
  33. * Convbrush - D. Kinder                                                     *
  34. * RevHead - D.M. Balean                                                     *
  35. * Zap - T. Rossi                                                            *
  36. * ADis - M. Apel                                                            *
  37. * FastWindows - R. Plant                                                    *
  38. * Memon - D. Ekholm                                                         *
  39. * PictSaver - P. Nielson                                                    *
  40. *                                                                           *
  41. * 1875 lines in 2.53 sec = 44466 lines/min.                                 *
  42. * Global symbols: 184                                                       *
  43. * Local symbols:  34                                                        *
  44. * Code:   1 section(s)    3487 bytes                                        *
  45. * Data:   1 section(s)    4336 bytes                                        *
  46. * BSS:    none                                                              *
  47. *                                                                           *
  48. * Thanx to my bestest friend and loyal supporter Kym.  She makes great      *
  49. * coffee and even better kids!                                              *
  50. *                                                                           *
  51. *****************************************************************************
  52. *                                                                           *
  53. * Date        Time         Version                                          *
  54. *                                                                           *
  55. * 01-Jan-1995 18.55.42.14  2                                                *
  56. * First coding.                                                             *
  57. *                                                                           *
  58. * 01-Jan-1995 19.58.29.05  2                                                *
  59. * Changed window definitions.                                               *
  60. *                                                                           *
  61. * 02-Jan-1995 14.12.51.01  2                                                *
  62. * Added "Generate" gadget and cleaned up some labelling.                    *
  63. *                                                                           *
  64. * 02-Jan-1995 22.41.12.01  2                                                *
  65. * Optimised window routines for backwards compatibility.                    *
  66. *                                                                           *
  67. * 03-Jan-1995 22.47.59.16  2                                                *
  68. * Corrected fault in program timing.  Added credits window and gadget.      *
  69. *                                                                           *
  70. * 04-Jan-1995 13.18.53.22  2                                                *
  71. * Updated window definitions to include gadget activation and immediate     *
  72. * window activation.  Changed window loop to include gadget branching.      *
  73. *                                                                           *
  74. * 04-Jan-1995 20.48.40.47  2                                                *
  75. * Rewrote loops and message handlers.  Gave into using includes so rewrote  *
  76. * library opening routines and exec calls.                                  *
  77. *                                                                           *
  78. * 04-Jan-1995 21.43.51.31  2                                                *
  79. * Added Infile, Outfile and Option Gadgets.                                 *
  80. *                                                                           *
  81. * 10-Jan-1995 13.23.43.36  2                                                *
  82. * Changed message loops to catch gadget IDCMP messages.  Altered credits    *
  83. * brush and data file.                                                      *
  84. *                                                                           *
  85. * 30-Jan-1995 11.01.07.45  2                                                *
  86. * Major revision.  Ditched includes, totally redesigned windows and         *
  87. * Gadgets (Gadgets now have alternate images).  Option gadgets mutually     *
  88. * exclusive.  Wb startup code modified.  New Gfx.                           *
  89. *                                                                           *
  90. * 31-Jan-1995 18.36.05.06  2                                                *
  91. * Defined and placed string gadgets.                                        *
  92. *                                                                           *
  93. * 03-Feb-1995 23.14.08.27  2                                                *
  94. * Finalised string gadgets, changed most gadgets to use default font        *
  95. * instead of image (what a risk!).  EdWordPro used text casing to make code *
  96. * look pretty, and added some headings, sectionalising code.                *
  97. *                                                                           *
  98. * 04-Feb-1995 14.21.53.37  2                                                *
  99. * Added file and option error routines and messages.                        *
  100. *                                                                           *
  101. * 04-Feb-1995 22.19.12.14  2                                                *
  102. * Improved error trapping and coded file access.                            *
  103. *                                                                           *
  104. * 05-Feb-1995 21.58.07.09  2                                                *
  105. * Sort of finished!  Some testing and debugging needed.  Add final file     *
  106. * manipulation and start/end line codes/definitions.                        *
  107. *                                                                           *
  108. * 06-Feb-1995 22.07.10.06  2                                                *
  109. * Cleared a couple of bugs and cleaned up exit routine.  Some commenting    *
  110. * left and then it's a wrap.                                                *
  111. *                                                                           *
  112. * 07-Feb-1995 11.50.31.33  2                                                *
  113. * Added disable gadget feature.  Widened windows.  Modified IDCMP handling  *
  114. * and changed Optionflag routine.                                           *
  115. *                                                                           *
  116. * 07-Feb-1995 23.00.24.18  2                                                *
  117. * Minor debugging and major commenting.  Smashed some little bugs/hidden    *
  118. * features(!).                                                              *
  119. *                                                                           *
  120. * 08-Feb-1995 23.15.07.18  2                                                *
  121. * Finished.  Stomped a bug which involved linefeed handling.  Finalised     *
  122. * comments and converted all outstanding decimal values to hexidecimal.     *
  123. *                                                                           *
  124. * 18-Feb-1995 22.52.20.19  2                                                *
  125. * O.K!  So I couldn't stay away from it!  Here I've added the ARP file      *
  126. * requester routines, and a little "beep" when the program has finished.    *
  127. * I just need to ADD the Dirbuff to the Filebuff and then it's complete     *
  128. * (except maybe for an ASL requester as well...)                            *
  129. *                                                                           *
  130. * 22-Feb-1995 08.50.20.23  2                                                *
  131. * Sorted out Dir+File routines (a bit sneakily, but then again the latest   *
  132. * edition to the Peck household thinks lack of sleep will help his dad, so  *
  133. * my efficiency rating has dropped somewhat).  I promise NOT to do anymore  *
  134. * updating!                                                                 *
  135. *                                                                           *
  136. * 23-Mar-1995 19.15.20.23  2                                                *
  137. * Small Arp bug stomped.                                                    *
  138. *                                                                           *
  139. * 22-Apr-1995 22.44.29.12  2                                                *
  140. * Some compatability problems with pre-WB2 systems.  My mum picked this one *
  141. * up.  Good one mum!  I knew that 1.2 A500 would come in handy one day...   *
  142. * While I was here I added a small requester routine in case the outfile    *
  143. * already exists.                                                           *
  144. *                                                                           *
  145. * 24-Feb-1996 21:59:22.43 2                                                 *
  146. * Added Asl requester.  I should fix up some memory routines but I can't be *
  147. * bothered!  Sorry!                                                         *
  148. *                                                                           *
  149. *****************************************************************************
  150.  
  151. *********************************************************************
  152. *                                                                   *
  153. * Some Useful Definitions                                           *
  154. * -----------------------                                           *
  155. *                                                                   *
  156. * You'll find all of these in the various includes that come with   *
  157. * a compiler like DevPac.  Some are defined in structures such as   *
  158. * "GADGET", while others are library offsets.  If you are stuck for *
  159. * such definitions, check out HexTract by Chas Wyndham (Fish 817).  *
  160. *                                                                   *
  161. *********************************************************************
  162.  
  163. ; Simple equivalents
  164.  
  165. ExecBase                = $04      ; ExecBase (!)
  166. Wd_rport                = $32      ; Window RastPort (Window structure)
  167. Wd_userport             = $56      ; Window UserPort (Window structure)
  168. Pr_cli                  = $AC      ; CLI offset in process structure
  169. Pr_msgport              = $5C      ; Message port for process structue
  170. Im_class                = $14      ; Class for IDCMP message
  171. Iaddress                = $1C      ; Address of IDCMP message
  172. Gg_gadgetid             = $26      ; Gadget ID (Gadget structure)
  173. Gadgetup                = $40      ; Gadget pressed
  174. Gadclosewindow          = $200     ; Close window pressed
  175. GadFlags                = $0C      ; Gadget status (Gadget structure)
  176. NumChars                = $10      ; Number of chars in stringinfo
  177. Mode_OLDFILE            = $03ED    ; Access mode for open file
  178. Mode_NEWFILE            = $03EE    ; Access mode for open file
  179. LF                      = $0A      ; LineFeed
  180. CR                      = $0D      ; Carriage Return
  181. Apost                   = $27      ; Apostrophe 
  182.  
  183. ; Library Vector Offsets
  184.  
  185. _LVOOpenlibrary         = -$0228   ; Exec function
  186. _LVOCloselibrary        = -$019E   ; Exec function
  187. _LVOArpFileRequest      = -$0126   ; ARP function
  188. _LVOTackOn              = -$0270   ; ARP function
  189. _LVOAllocAslRequest     = -$0030   ; Asl function
  190. _LVOAslRequest          = -$003C   ; Asl function
  191. _LVOFreeFileRequest     = -$0024   ; Asl function
  192. _LVOOpenwindow          = -$CC     ; Intuition function
  193. _LVOOpen                = -$1E     ; Dos function
  194. _LVOClose               = -$24     ; Dos function
  195. _LVORead                = -$2A     ; Dos function
  196. _LVODelay               = -$C6     ; Dos function
  197. _LVOWrite               = -$30     ; Dos function
  198. _LVODrawimage           = -$72     ; Intuition function
  199. _LVOWaitport            = -$0180   ; Exec function
  200. _LVOFindtask            = -$0126   ; Exec function
  201. _LVOForbid              = -$84     ; Exec function
  202. _LVOClosewindow         = -$48     ; Intuition function
  203. _LVOSetwindowtitles     = -$0114   ; Intuition function
  204. _LVOGetmsg              = -$0174   ; Exec function
  205. _LVOReplymsg            = -$017A   ; Exec function
  206. _LVOOffGadget           = -$AE     ; Exec function
  207. _LVOAddGadget           = -$2A     ; Intuition function
  208. _LVORefreshgadgets      = -$DE     ; Intuition function
  209. _LVODisplayBeep         = -$60     ; Intuition function
  210. _LVOAutoRequest         = -$015C   ; Intuition function
  211.  
  212. *********************************************************************
  213. *                                                                   *
  214. * Some Useful Macros                                                *
  215. * ------------------                                                *
  216. *                                                                   *
  217. * Macros waste memory and increase the size of the code, but they   *
  218. * make life a bit easier and the code a bit more readable.  All of  *
  219. * these are used to access the appropriate library functions.  The  *
  220. * library bases are loaded, the LVO prefix is added, and then the   *
  221. * function is called.  Simple!                                      *
  222. *                                                                   *
  223. *********************************************************************
  224.  
  225. EXEC            Macro
  226.         MOVE.L  ExecBase,A6        ; Move Exec into a6
  227.         JSR     _LVO\1(A6)         ; Add Library offset and call function
  228.                 Endm
  229.  
  230. CALLINT         Macro
  231.         MOVE.L  _intuitionbase,A6  ; Move Intuition into a6
  232.         JSR     _LVO\1(A6)         ; Add Library offset and call function
  233.                 Endm
  234.  
  235. CALLDOS         Macro
  236.         MOVE.L  _dosbase,A6        ; Move Dos into a6
  237.         JSR     _LVO\1(A6)         ; Add Library offset and call function
  238.                 Endm
  239.  
  240. CALLREQ         MACRO
  241.         MOVE.L  _reqbase,A6        ; Move REQ LIB into a6
  242.         JSR     _LVO\1(A6)         ; Add Library offset and call function
  243.                 ENDM
  244.  
  245. *********************************************************************
  246. *                                                                   *
  247. * Wb Startup Code                                                   *
  248. * ---------------                                                   *
  249. *                                                                   *
  250. * I modified this slightly from that which is provided with the     *
  251. * includes that come with DevPac.  You can get similiar code        *
  252. * in the Public Domain, see STARTUPS on Fish 101.  All they do is   *
  253. * allow you to start your program from WB.                          *
  254. *                                                                   *
  255. *********************************************************************
  256.  
  257.         MOVEM.L  D0/A0,-(SP)        ;    save initial values
  258.         CLR.L    Returnmsg          ;    clear message
  259.         SUB.L    A1,A1              ;    subtract address
  260.         EXEC     Findtask           ;    find us
  261.         MOVE.L   D0,A4              ;    move process to a4
  262.         TST.L    Pr_cli(A4)         ;    test if CLI
  263.         BEQ      Fromworkbench      ;    otherwise go to workbench
  264.         MOVEM.L  (SP)+,D0/A0        ;    restore registers
  265.         BRA      End_startup        ;    and run the program
  266.  
  267. Fromworkbench:
  268.  
  269.         LEA      Pr_msgport(A4),A0  ;    load the message port
  270.         EXEC     Waitport           ;    wait for a message
  271.         LEA      Pr_msgport(A4),A0  ;    load the message port
  272.         EXEC     Getmsg             ;    then get it
  273.         MOVE.L   D0,Returnmsg       ;    save it for later reply
  274.         MOVEM.L  (SP)+,D0/A0        ;    restore registers
  275.  
  276. End_startup:
  277.  
  278.         BSR      Start              ;    call the program
  279.         MOVE.L   D0,-(SP)           ;    save it
  280.         TST.L    Returnmsg          ;    test if message
  281.         BEQ      Exittodos          ;    if I was a CLI
  282.         EXEC     Forbid             ;    forbid WB to close
  283.         MOVE.L   Returnmsg(Pc),A1   ;    load message
  284.         EXEC     Replymsg           ;    message received!
  285.  
  286. Exittodos:
  287.  
  288.         MOVE.L   (SP)+,D0           ;    exit code
  289.         RTS
  290.  
  291. *********************************************************************
  292. *                                                                   *
  293. * Program Starts Here                                               *
  294. * -------------------                                               *
  295. *                                                                   *
  296. * The above code points to this Start identifier, which is where    *
  297. * the actual program starts!                                        *
  298. *                                                                   *
  299. *********************************************************************
  300.  
  301. Start:
  302.  
  303. ; The following subroutines can be found in the "SUBROUTINES" section.
  304.  
  305.         BSR     Openint             ; Open intuition library
  306.         BSR     Opendos             ; Open dos library
  307.         BSR     Win                 ; Open window
  308.         BSR     Marketing_Win       ; Draw images on window
  309.  
  310. Aslavail:
  311.  
  312. ; We'll find out if the Asl library is available.  If so, we can add two
  313. ; gadgets to the window which will enable the lazy user to select the
  314. ; infile and outfile using the Asl file requester.
  315.  
  316.         LEA      Aslname,A1         ; Load ASL library into a1
  317.         MOVE.L   #$00,D0            ; Any version will do
  318.         EXEC     Openlibrary        ; Macro opens library
  319.         BEQ      ArpAvail           ; If there's a problem, go for Arp
  320.         MOVE.L   D0,_reqbase        ; Save the return address
  321.         MOVE.L   Winhd,A0           ; Load window handle to A0
  322.         LEA      Inreq,A1           ; Load the Req gadget for infile
  323.         CALLINT  AddGadget          ; Add it to the list
  324.         MOVE.L   Winhd,A0           ; Load window handle to A0
  325.         LEA      Outreq,A1          ; Load the Req gadget for outfile
  326.         CALLINT  AddGadget          ; Add it to the list
  327.         BRA      RefGads            ; Go and refresh the gadgets
  328.  
  329. ArpAvail:
  330.  
  331. ; We'll find out if the ARP library is available.  If so, we can add two
  332. ; gadgets to the window which will enable the lazy user to select the
  333. ; infile and outfile using the ARP file requester.
  334.  
  335.         LEA      Arpname,A1         ; Load ARP library into a1
  336.         MOVE.L   #$00,D0            ; Any version will do
  337.         EXEC     Openlibrary        ; Macro opens library
  338.         BEQ      Mainloop           ; If there's a problem, continue
  339.         MOVE.B   #1,IsArpOpen       ; Flag that library
  340.         MOVE.L   D0,_reqbase        ; Save the return address
  341.         MOVE.L   Winhd,A0           ; Load window handle to A0
  342.         LEA      Inreq,A1           ; Load the Req gadget for infile
  343.         CALLINT  AddGadget          ; Add it to the list
  344.         MOVE.L   Winhd,A0           ; Load window handle to A0
  345.         LEA      Outreq,A1          ; Load the Req gadget for outfile
  346.         CALLINT  AddGadget          ; Add it to the list
  347.         BRA      RefGads            ; Go and refresh the gadgets
  348.  
  349. Mainloop:
  350.  
  351. ; This window is where all the action occurs.  From here the user
  352. ; selects the files to be processed, and the conversion option required.
  353.  
  354.         BSR      Waitformess        ; Bide time until user inputs
  355.         MOVE.L   Winhd,A0           ; Move window handle into a0
  356.         MOVE.L   Wd_userport(A0),A0 ; UserPort offset
  357.         EXEC     Getmsg             ; Macro gets window message
  358.         MOVE.L   D0,A1              ; Message transferred to a1
  359.         MOVE.L   A1,Message         ; Message saved for analysis
  360.         EXEC     Replymsg           ; Message received!
  361.         MOVE.L   Message,A0         ; Load message into a0
  362.         MOVE.L   Im_class(A0),D0    ; Message class offset
  363.         CMPI.L   #Gadclosewindow,D0 ; Was the close gadget pressed
  364.         BEQ      Cleanup            ; Yes!  Outta here...
  365.         MOVE.L   Message,A0         ; ...else Load message into a0
  366.         MOVE.L   Iaddress(A0),A0    ; Gadget address offset
  367.         MOVE.L   Gg_gadgetid(A0),D0 ; Gadget ID offset
  368.  
  369.         CMPI.L   #$10000,D0         ; Was the "GENERATE" gadget pressed
  370.         BEQ      Errors             ; Yes!  See if there are any errors
  371.  
  372.         CMPI.L   #$20000,D0         ; Was the "SCRIPT" gadget pressed
  373.         BEQ      Gadscriptact       ; Yes!  Activate Script Option
  374.  
  375.         CMPI.L   #$30000,D0         ; Was the "PASCAL" gadget pressed
  376.         BEQ      Gadpasact          ; Yes!  Activate Pascal Option
  377.  
  378.         CMPI.L   #$40000,D0         ; Was the "C" gadget pressed
  379.         BEQ      Gadcact            ; Yes!  Activate C Option
  380.  
  381.         CMPI.L   #$70000,D0         ; Was the "Infile" req gadget pressed
  382.         BEQ      Gadifreq           ; Yes!  Activate ARP requester
  383.  
  384.         CMPI.L   #$80000,D0         ; Was the "Outfile" req gadget pressed
  385.         BEQ      Gadofreq           ; Yes!  Activate ARP requester
  386.  
  387.         BRA      Mainloop           ; Go Mainloop ->
  388.  
  389. Gadscriptact:
  390.  
  391. ; This next section firstly checks the Optionflag.  If this gadget has
  392. ; already been activated then the flag is reset to zero, else it is set
  393. ; to 1.  Then the other gadgets are checked.  If they are activated, they
  394. ; are deactivated.  Finally the gadgets are "Refreshed" and we are then
  395. ; sent back to the Mainloop.  The $0006 refers to the image type and
  396. ; gadget activation mode, while the $0086 is the same flag but now the
  397. ; gadget has been activated.
  398.  
  399.         CMP.B   #$01,Optionflag     ; Is the option already flagged?
  400.         BEQ     1$                  ; Yes!  Branch to reset...
  401.         MOVE.B  #$01,Optionflag     ; ...else set to 1...
  402.         BRA     2$                  ; ...then jump to second marker
  403. 1$:     CLR.B   Optionflag          ; Clear the option flag
  404. 2$:     LEA     Gadscript,A2        ; Load the script gadget structure
  405.         MOVE.L  GadFlags(A2),D0     ; Move to flag offset
  406.         CMPI.W  #$0086,D0           ; Is the gadget already pressed?
  407.         BEQ     RefGads             ; Yes!  Refresh and go...
  408.         LEA     Gadpascal,A0        ; Load next gadget
  409.         CMPI.W  #$0006,GadFlags(A0) ; Is the gadget not pressed?
  410.         BEQ     3$                  ; Yes! Refresh and go...
  411.         MOVE.W  #$0006,GadFlags(A0) ; ...else "unpress" gadget
  412. 3$:     LEA     Gadc,A0             ; Load next gadget
  413.         CMPI.W  #$0006,GadFlags(A0) ; Is the gadget not pressed?
  414.         BEQ     4$                  ; Yes! Refresh and go...
  415.         MOVE.W  #$0006,GadFlags(A0) ; ...else "unpress" gadget
  416. 4$:     BRA     RefGads             ; Go Refresh ->
  417.  
  418. Gadpasact:
  419.  
  420. ; This next section firstly checks the Optionflag.  If this gadget has
  421. ; already been activated then the flag is reset to zero, else it is set
  422. ; to 2.  Then the other gadgets are checked.  If they are activated, they
  423. ; are deactivated.  Finally the gadgets are "Refreshed" and we are then
  424. ; sent back to the Mainloop.  The $0006 refers to the image type and
  425. ; gadget activation mode, while the $0086 is the same flag but now the
  426. ; gadget has been activated.
  427.  
  428.         CMP.B   #$02,Optionflag     ; Is the option already flagged?  
  429.         BEQ     1$                  ; Yes!  Branch to reset...
  430.         MOVE.B  #$02,Optionflag     ; ...else set to 2...
  431.         BRA     2$                  ; ...then jump to second marker
  432. 1$:     CLR.B   Optionflag          ; Clear the option flag
  433. 2$:     LEA     Gadpascal,A2        ; Load the script gadget structure
  434.         MOVE.L  GadFlags(A2),D0     ; Move to flag offset
  435.         CMPI.W  #$0086,D0           ; Is the gadget already pressed?
  436.         BEQ     RefGads             ; Yes!  Refresh and go...
  437.         LEA     Gadc,A0             ; Load next gadget
  438.         CMPI.W  #$0006,GadFlags(A0) ; Is the gadget not pressed?
  439.         BEQ     3$                  ; Yes! Refresh and go...
  440.         MOVE.W  #$0006,GadFlags(A0) ; ...else "unpress" gadget
  441. 3$:     LEA     Gadscript,A0        ; Load next gadget
  442.         CMPI.W  #$0006,GadFlags(A0) ; Is the gadget not pressed?
  443.         BEQ     4$                  ; Yes! Refresh and go...
  444.         MOVE.W  #$0006,GadFlags(A0) ; ...else "unpress" gadget
  445. 4$:     BRA     RefGads             ; Go Refresh ->
  446.  
  447. Gadcact:
  448.  
  449. ; This next section firstly checks the Optionflag.  If this gadget has
  450. ; already been activated then the flag is reset to zero, else it is set
  451. ; to 3.  Then the other gadgets are checked.  If they are activated, they
  452. ; are deactivated.  Finally the gadgets are "Refreshed" and we are then
  453. ; sent back to the Mainloop.  The $0006 refers to the image type and
  454. ; gadget activation mode, while the $0086 is the same flag but now the
  455. ; gadget has been activated.
  456.  
  457.         CMP.B   #$03,Optionflag     ; Is the option already flagged?
  458.         BEQ     1$                  ; Yes!  Branch to reset...
  459.         MOVE.B  #$03,Optionflag     ; ...else set to 3...
  460.         BRA     2$                  ; ...then jump to second marker
  461. 1$:     CLR.B   Optionflag          ; Clear the option flag
  462. 2$:     LEA     Gadc,A2             ; Load the script gadget structure
  463.         MOVE.L  GadFlags(A2),D0     ; Move to flag offset
  464.         CMPI.W  #$0086,D0           ; Is the gadget already pressed?
  465.         BEQ     RefGads             ; Yes!  Refresh and go...
  466.         LEA     Gadscript,A0        ; Load next gadget
  467.         CMPI.W  #$0006,GadFlags(A0) ; Is the gadget not pressed?
  468.         BEQ     3$                  ; Yes! Refresh and go...
  469.         MOVE.W  #$0006,GadFlags(A0) ; ...else "unpress" gadget
  470. 3$:     LEA     Gadpascal,A0        ; Load next gadget
  471.         CMPI.W  #$0006,GadFlags(A0) ; Is the gadget not pressed?
  472.         BEQ     4$                  ; Yes! Refresh and go...
  473.         MOVE.W  #$0006,GadFlags(A0) ; ...else "unpress" gadget
  474. 4$:     BRA     RefGads             ; Go Refresh ->
  475.  
  476. Gadifreq:
  477.  
  478. ; If the Infile Requester Gadget is pressed, we need to fire up a
  479. ; requester, and we start with the preferable Asl requester.
  480.  
  481.         TST.B   IsArpOpen          ; Are we Arping today?
  482.         BNE     Arpifreq           ; Yes, so outta this Asl territory
  483.  
  484.         MOVE.L  #0,A0              ; I'll be initiating a...
  485.         CLR.L   D0                 ; ...File Requester...
  486.         CALLREQ AllocAslRequest    ; ...if that's OK with you!
  487.         MOVE.L  D0,A4              ; Else move the requester to A4
  488.         MOVE.L  D0,A0              ; A copy to A0
  489.         CALLREQ AslRequest         ; And fire it up!
  490.         MOVE.L  4(A4),A1           ; Move the resultant file info to A1
  491.         MOVE.L  8(A4),A2           ; and the Path info to A2
  492.  
  493.         LEA     Infilebuff,A0      ; Get the buffer ready in A0
  494.         MOVE.L  #$64,D0            ; And the size is 100
  495.         BSR     ClearBuff;         ; Clear it baby!
  496.  
  497.         LEA     Infilebuff,A3      ; Now load it to A3
  498.         MOVE.B  #$64,D3            ; And it's size to D3
  499.  
  500.         TST.B   (A2)               ; Any path info?
  501.         BEQ     3$                 ; No so move on to the file info
  502.  
  503. 1$      MOVE.B  (A2)+,D0           ; Else move a byte to D0
  504.         TST.B   D0                 ; Test it's validity
  505.         BEQ     2$                 ; No good so finished
  506.         MOVE.B  D0,(A3)+           ; else move it to the Infile buffer
  507.         SUB.B   #1,D3              ; decrement counter
  508.         TST.B   D3                 ; at zero yet?
  509.         BNE     1$                 ; No so back for another character
  510.  
  511. ; If we've run outta space we gotta tell the punters.
  512.  
  513.         MOVE.L  #$00,A0            ; All screens to beep!
  514.         CALLINT DisplayBeep        ; Beep the display to wake up user
  515.         LEA     BigPath,A1         ; ...else load the message pointer...
  516.         BRA     ErrorMessage       ; ...and display the error
  517.  
  518. 2$      MOVE.B  -1(A3),D0          ; What was that last one?
  519.         CMP.B   #$3A,D0            ; Was it a full colon?
  520.         BEQ     3$                 ; Yep, so move on to file info
  521.         MOVE.B  #$2F,(A3)+         ; Move in a "/"
  522.         SUB.B   #1,D3              ; decrement counter
  523.         TST.B   D3                 ; at zero yet?
  524.         BNE     3$                 ; No so move along to file info
  525.  
  526. ; It'd be a bummer if the backslash was the last character, but it could
  527. ; happen so we will notify the user.
  528.  
  529.         MOVE.L  #$00,A0            ; All screens to beep!
  530.         CALLINT DisplayBeep        ; Beep the display to wake up user
  531.         LEA     BigPath,A1         ; ...else load the message pointer...
  532.         BRA     ErrorMessage       ; ...and display the error
  533.  
  534. 3$      MOVE.B  (A1)+,D0           ; Move the file info character
  535.         TST.B   D0                 ; Hello?
  536.         BEQ     4$                 ; Yikes, outta here.
  537.         MOVE.B  D0,(A3)+           ; else add it to infile buffer
  538.         SUB.B   #1,D3              ; and decrement counter
  539.         TST.B   D3                 ; at zero yet?
  540.         BNE     3$                 ; Nope, so another character?
  541.  
  542.         MOVE.L  #$00,A0            ; All screens to beep!
  543.         CALLINT DisplayBeep        ; Beep the display to wake up user
  544.         LEA     BigPath,A1         ; ...else load the message pointer...
  545.         BRA     ErrorMessage       ; ...and display the error
  546.  
  547. 4$      MOVE.L  A4,A0              ; The last hurrah
  548.         CALLREQ FreeFileRequest    ; is to free the requester
  549.  
  550.         BRA     RefGads            ; and then off to refresh gadgets
  551.  
  552. Arpifreq:
  553.  
  554. ; We simply load the requester to A0 and then call the library function.
  555. ; The Arp function "TackOn" adds the file name to the pathname.
  556.  
  557.         LEA      Infilebuff,A0      ; Load the Infile buffer
  558.         MOVE.L   #$64,D0            ; ...and the size of the buffer
  559.         BSR      ClearBuff          ; We may need this buffer clear!
  560.         LEA      ArpDirBuff,A0      ; Load the Arp Directory buffer
  561.         MOVE.L   #$46,D0            ; ...and the size of the buffer
  562.         BSR      ClearBuff          ; We may need this buffer clear!
  563.         LEA      Arpfrequest,A0     ; Load the requester structure
  564.         CALLREQ  ArpFileRequest     ; Call the Requester
  565.         LEA      ArpDirBuff,A0      ; Load the Arp Directory buffer
  566.         LEA      ArpFileBuff,A1     ; Load the Arp File buffer
  567.         CALLREQ  TackOn             ; Macro calls function
  568.         LEA      ArpDirBuff,A0      ; Reload Arp Directory buffer
  569.         LEA      Infilebuff,A1      ; Load the Infile buffer
  570. 1$      MOVE.B   (A0)+,D0           ; Move a character to D0
  571.         CMPI.B   #$00,D0            ; Is it a dud?
  572.         BEQ      2$                 ; Yes -> move along...
  573.         MOVE.B   D0,(A1)+           ; ...else add it to Infile buffer
  574.         BRA      1$                 ; ...and return
  575. 2$      BRA      RefGads            ; clean up gadgets ->
  576.  
  577. Gadofreq:
  578.  
  579. ; If the Outfile Requester Gadget is pressed, we need to fire up a
  580. ; requester, and we start with the preferable Asl requester.
  581.  
  582.         TST.B   IsArpOpen          ; Are we Arping today?
  583.         BNE     Arpofreq           ; Yes, so outta this Asl territory
  584.  
  585.         MOVE.L  #0,A0              ; I'll be initiating a...
  586.         CLR.L   D0                 ; ...File Requester...
  587.         CALLREQ AllocAslRequest    ; ...if that's OK with you!
  588.         MOVE.L  D0,A4              ; Else move the requester to A4
  589.         MOVE.L  D0,A0              ; A copy to A0
  590.         CALLREQ AslRequest         ; And fire it up!
  591.         MOVE.L  4(A4),A1           ; Move the resultant file info to A1
  592.         MOVE.L  8(A4),A2           ; and the Path info to A2
  593.  
  594.         LEA     Outfilebuff,A0     ; Get the buffer ready in A0
  595.         MOVE.L  #$64,D0            ; And the size is 100
  596.         BSR     ClearBuff;         ; Clear it baby!
  597.  
  598.         LEA     Outfilebuff,A3     ; Now load it to A3
  599.         MOVE.B  #$64,D3            ; And it's size to D3
  600.  
  601.         TST.B   (A2)               ; Any path info?
  602.         BEQ     3$                 ; No so move on to the file info
  603.  
  604. 1$      MOVE.B  (A2)+,D0           ; Else move a byte to D0
  605.         TST.B   D0                 ; Test it's validity
  606.         BEQ     2$                 ; No good so finished
  607.         MOVE.B  D0,(A3)+           ; else move it to the Infile buffer
  608.         SUB.B   #1,D3              ; decrement counter
  609.         TST.B   D3                 ; at zero yet?
  610.         BNE     1$                 ; No so back for another character
  611.  
  612. ; If we've run outta space we gotta tell the punters.
  613.  
  614.         MOVE.L  #$00,A0            ; All screens to beep!
  615.         CALLINT DisplayBeep        ; Beep the display to wake up user
  616.         LEA     BigPath,A1         ; ...else load the message pointer...
  617.         BRA     ErrorMessage       ; ...and display the error
  618.  
  619. 2$      MOVE.B  -1(A3),D0          ; What was that last one?
  620.         CMP.B   #$3A,D0            ; Was it a full colon?
  621.         BEQ     3$                 ; Yep, so move on to file info
  622.         MOVE.B  #$2F,(A3)+         ; Move in a "/"
  623.         SUB.B   #1,D3              ; decrement counter
  624.         TST.B   D3                 ; at zero yet?
  625.         BNE     3$                 ; No so move along to file info
  626.  
  627. ; It'd be a bummer if the backslash was the last character, but it could
  628. ; happen so we will notify the user.
  629.  
  630.         MOVE.L  #$00,A0            ; All screens to beep!
  631.         CALLINT DisplayBeep        ; Beep the display to wake up user
  632.         LEA     BigPath,A1         ; ...else load the message pointer...
  633.         BRA     ErrorMessage       ; ...and display the error
  634.  
  635. 3$      MOVE.B  (A1)+,D0           ; Move the file info character
  636.         TST.B   D0                 ; Hello?
  637.         BEQ     4$                 ; Yikes, outta here.
  638.         MOVE.B  D0,(A3)+           ; else add it to infile buffer
  639.         SUB.B   #1,D3              ; and decrement counter
  640.         TST.B   D3                 ; at zero yet?
  641.         BNE     3$                 ; Nope, so another character?
  642.  
  643.         MOVE.L  #$00,A0            ; All screens to beep!
  644.         CALLINT DisplayBeep        ; Beep the display to wake up user
  645.         LEA     BigPath,A1         ; ...else load the message pointer...
  646.         BRA     ErrorMessage       ; ...and display the error
  647.  
  648. 4$      MOVE.L  A4,A0              ; The last hurrah
  649.         CALLREQ FreeFileRequest    ; is to free the requester
  650.  
  651.         BRA     RefGads            ; and then off to refresh gadgets
  652.  
  653. Arpofreq:
  654.  
  655. ; We simply load the requester to A0 and then call the library function.
  656. ; The Arp function "TackOn" adds the file name to the pathname.
  657.  
  658.         LEA      Outfilebuff,A0     ; Load the Outfile buffer
  659.         MOVE.L   #$64,D0            ; ...and the size of the buffer
  660.         BSR      ClearBuff          ; We may need this buffer clear!
  661.         LEA      ArpDirBuff,A0      ; Load the Arp Directory buffer
  662.         MOVE.L   #$46,D0            ; ...and the size of the buffer
  663.         BSR      ClearBuff          ; We may need this buffer clear!
  664.         LEA      Arpfrequest,A0     ; Load the requester structure
  665.         CALLREQ  ArpFileRequest     ; Call the Requester
  666.         LEA      ArpDirBuff,A0      ; Load the Arp Directory buffer
  667.         LEA      ArpFileBuff,A1     ; Load the Arp File buffer
  668.         CALLREQ  TackOn             ; Macro calls function
  669.         LEA      ArpDirBuff,A0      ; Reload Arp Directory buffer
  670.         LEA      Outfilebuff,A1     ; Load the Outfile buffer
  671. 1$      MOVE.B   (A0)+,D0           ; Move a character to D0
  672.         CMPI.B   #$00,D0            ; Is it a dud?
  673.         BEQ      2$                 ; Yes -> move along...
  674.         MOVE.B   D0,(A1)+           ; ...else add it to Outfile
  675.         BRA      1$                 ; ...and return
  676. 2$      BRA      RefGads            ; clean up gadgets ->
  677.  
  678. RefGads:
  679.  
  680. ; Here we refresh the gadgets after changes have been made.
  681.  
  682.         LEA      Gadgenerate,A0     ; Load address of first gadget
  683.         MOVE.L   Winhd,A1           ; Load window pointer
  684.         MOVE.L   #$00,A2            ; No requester
  685.         CALLINT  Refreshgadgets     ; Macro calls function
  686.         BRA      Mainloop           ; Go Mainloop ->
  687.  
  688. Errors:
  689.  
  690. ; If the "GENERATE" gadget was pressed, we need to check to see that some
  691. ; basic condition have been satisfied.  E.g. Has an infile and outfile
  692. ; been selected?  Has an option been selected?  Can I find and open the
  693. ; files?
  694.  
  695.         CLR.L   D0                  ; First a clean slate
  696.  
  697. Checkinfile:
  698.  
  699.         LEA     Infileinfo,A0       ; Load the infile structure
  700.         MOVE.W  NumChars(A0),D0     ; Move to number of characters offset
  701.         TST.B   D0                  ; Test if anything was entered
  702.         BNE     Checkoutfile        ; If OK move on...
  703.         MOVE.L  #$00,A0             ; All screens to beep!
  704.         CALLINT DisplayBeep         ; Beep the display to wake up user
  705.         LEA     NoInfile,A1         ; ...else load the message pointer...
  706.         BRA     ErrorMessage        ; ...and display the error
  707.  
  708. Checkoutfile:
  709.  
  710.         LEA     Outfileinfo,A0      ; Load the outfile structure
  711.         MOVE.W  NumChars(A0),D0     ; Move to number of characters offset
  712.         TST.B   D0                  ; Test if anything was entered
  713.         BNE     Checkoptionflag     ; If OK move on...
  714.         MOVE.L  #$00,A0             ; All screens to beep!
  715.         CALLINT DisplayBeep         ; Beep the display to wake up user
  716.         LEA     NoOutfile,A1        ; ...else load the message pointer...
  717.         BRA     ErrorMessage        ; ...and display the error
  718.  
  719. Checkoptionflag:
  720.  
  721.         MOVE.B  Optionflag,D0       ; Move optionflag to D3
  722.         TST.B   D0                  ; Test if option has been selected
  723.         BNE     OpenFiles           ; If OK move on...
  724.         MOVE.L  #$00,A0             ; All screens to beep!
  725.         CALLINT DisplayBeep         ; Beep the display to wake up user
  726.         LEA     NoOption,A1         ; ...else load the message pointer...
  727.         BRA     ErrorMessage        ; ...and display the error
  728.  
  729. OpenFiles:
  730.  
  731. ; Now that any errors have been dealt with, we can open the infile and 
  732. ; the outfile.
  733.  
  734.         MOVE.L  #Infilebuff,D1      ; Move the name of the infile to D1
  735.         MOVE.L  #Mode_OLDFILE,D2    ; Opening as an existing file
  736.         CALLDOS Open                ; Macro calls open function
  737.         TST.B   D0                  ; Open OK?
  738.         BNE     1$                  ; Yes! Move on...
  739.         MOVE.L  #$00,A0             ; All screens to beep!
  740.         CALLINT DisplayBeep         ; Beep the display to wake up user
  741.         LEA     NoInfileAcc,A1      ; ...else load the message pointer...
  742.         BRA     ErrorMessage        ; ...and display the error
  743. 1$      MOVE.L  D0,Infilehd         ; Save the infile handle
  744.  
  745. ; We need to check if the outfile exists, and alert the user...
  746.  
  747.         MOVE.L  #Outfilebuff,D1     ; Move the name of the outfile to D1
  748.         MOVE.L  #Mode_OLDFILE,D2    ; Opening as a old file first
  749.         CALLDOS Open                ; Macro calls open function
  750.         MOVE.L  D0,Outfilehd        ; Save the file handle
  751.         TST.B   D0                  ; Test if the file already exists
  752.         BEQ     2$                  ; If "NO" then move on ->
  753.         MOVE.L  Winhd,A0            ; ...else load the window handle to A0
  754.         LEA     Atext,A1            ; ...and the main body text to A1
  755.         LEA     Ltext,A2            ; ...and the left text to A2
  756.         LEA     Rtext,A3            ; ...and the right text to A3
  757.         MOVE.L  #$00,D0             ; left button responds to mouse click
  758.         MOVE.L  #$00,D1             ; right button responds to mouse click
  759.         MOVE.L  #$C4,D2             ; requester length
  760.         MOVE.L  #$35,D3             ; requester height
  761.         CALLINT AutoRequest         ; call the requester
  762.         TST.B   D0                  ; Test if clicked the right button
  763.         BEQ     2$                  ; Yes...so move on
  764.  
  765. ; Closing the files just in case we don't get back here again!
  766.  
  767.         MOVE.L  Infilehd,D1         ; No...so load infile handle...
  768.         CALLDOS Close               ; ...and close the file...
  769.         MOVE.L  Outfilehd,D1        ; Load the outfile handle
  770.         CALLDOS Close               ; ...and close the file...
  771.         MOVE.L  #$00,A0             ; All screens to beep!
  772.         CALLINT DisplayBeep         ; Beep the display to wake up user
  773.         BRA     Mainloop            ; Head back to main window
  774. 2$      MOVE.L  Outfilehd,D1        ; Load the outfile handle
  775.         CALLDOS Close               ; Macro calls function
  776.  
  777. ; Now we open the old file, knowing that all is OK with the user...
  778.  
  779.         MOVE.L  #Outfilebuff,D1     ; Move the name of the outfile to D1
  780.         MOVE.L  #Mode_NEWFILE,D2    ; Opening as a new file now
  781.         CALLDOS Open                ; Macro calls open function
  782.         TST.B   D0                  ; Open OK?
  783.         BNE     3$                  ; Yes! Move on...
  784.         MOVE.L  Infilehd,D1         ; If error load infile handle...
  785.         CALLDOS Close               ; ...and close the file...
  786.         MOVE.L  #$00,A0             ; All screens to beep!
  787.         CALLINT DisplayBeep         ; Beep the display to wake up user
  788.         LEA     NoOutfileAcc,A1     ; ...then load the message pointer...
  789.         BRA     ErrorMessage        ; ...and display the error
  790. 3$      MOVE.L  D0,Outfilehd        ; Save the outfile handle
  791.         
  792. CloseGadgets:
  793.  
  794. ; Now that all the errors have been dealt with and the files are open, we
  795. ; can start the real work.  It's a good idea to shut down the gadgets and
  796. ; display a suitable message, just to show the user that something is
  797. ; happening.
  798.  
  799.         CMP.L   #$00,_ARPbase       ; Is ARP open (and the REQ gadgets)?
  800.         BEQ     1$                  ; No! Move along...
  801.         LEA     Inreq,A0            ; Load gadget into A0
  802.         MOVE.L  Winhd,A1            ; Move window handle into A1
  803.         MOVE.L  #$00,A2             ; No requester
  804.         CALLINT OffGadget           ; Macro turns off gadget
  805.         LEA     Outreq,A0           ; Load gadget into A0
  806.         MOVE.L  Winhd,A1            ; Move window handle into A1
  807.         MOVE.L  #$00,A2             ; No requester
  808.         CALLINT OffGadget           ; Macro turns off gadget
  809. 1$      LEA     Gadgenerate,A0      ; Load gadget into A0
  810.         MOVE.L  Winhd,A1            ; Move window handle into A1
  811.         MOVE.L  #$00,A2             ; No requester
  812.         CALLINT OffGadget           ; Macro turns off gadget
  813.         LEA     Gadscript,A0        ; Load gadget into A0
  814.         MOVE.L  Winhd,A1            ; Move window handle into A1
  815.         MOVE.L  #$00,A2             ; No requester
  816.         CALLINT OffGadget           ; Macro turns off gadget
  817.         LEA     Gadpascal,A0        ; Load gadget into A0
  818.         MOVE.L  Winhd,A1            ; Move window handle into A1
  819.         MOVE.L  #$00,A2             ; No requester
  820.         CALLINT OffGadget           ; Macro turns off gadget
  821.         LEA     Gadc,A0             ; Load gadget into A0
  822.         MOVE.L  Winhd,A1            ; Move window handle into A1
  823.         MOVE.L  #$00,A2             ; No requester
  824.         CALLINT OffGadget           ; Macro turns off gadget
  825.         LEA     Gadgenerate,A0      ; Load first gadget into A0
  826.         MOVE.L  Winhd,A1            ; Move window handle into A1
  827.         MOVE.L  #$00,A2             ; No requester
  828.         CALLINT Refreshgadgets      ; Macro calls function
  829.         LEA     Working,A1          ; Load working message to A1
  830.         MOVE.L  Winhd,A0            ; Move window handle into a0
  831.         LEA     Screentitle,A2      ; Load the screen title into a2
  832.         CALLINT Setwindowtitles     ; Macro changes screen title
  833.  
  834. WhichOption:
  835.  
  836. ; This code checks to see which of the option buttons was activated, and
  837. ; then loads data particular to that option into various registers, ready
  838. ; for use later, as well as writing a little message to the outfile about
  839. ; how the text got there in the first place (vanity oh vanity).
  840.  
  841.         CMP.B   #$01,Optionflag     ; Is script the option selected?
  842.         BNE     1$                  ; No!  Move on...
  843.         MOVE.L  Outfilehd,D1        ; Move Outfile handle to D1
  844.         MOVE.L  #Scblurb,D2         ; Move the message to D2
  845.         MOVE.L  #SIZEScBlurb,D3     ; Move the size of the message to D3
  846.         CALLDOS Write               ; Macro write to file
  847.         MOVE.L  #Scstart,D4         ; Move startline to D4
  848.         MOVE.L  #Scend,D5           ; Move endline to D5
  849.         MOVE.L  #SIZEScstart,D6     ; Size of startline to D6
  850.         MOVE.L  #SIZEScend,D7       ; Size of endline to D7
  851.         BRA     Primeloop           ; Go Primeloop ->
  852. 1$      CMP.B   #$02,Optionflag     ; Is Pascal the option selected?
  853.         BNE     2$                  ; No!  Move on..(C option by default)
  854.         MOVE.L  Outfilehd,D1        ; Move Outfile handle to D1
  855.         MOVE.L  #Pasblurb,D2        ; Move the message to D2
  856.         MOVE.L  #SIZEPasBlurb,D3    ; Move the size of the message to D3
  857.         CALLDOS Write               ; Macro write to file
  858.         MOVE.L  #Passtart,D4        ; Move startline to D4
  859.         MOVE.L  #Pasend,D5          ; Move endline to D5
  860.         MOVE.L  #SIZEPasstart,D6    ; Size of startline to D6
  861.         MOVE.L  #SIZEPasend,D7      ; Size of endline to D7
  862.         BRA     Primeloop           ; Go Primeloop ->
  863. 2$      MOVE.L  Outfilehd,D1        ; Move Outfile handle to D1
  864.         MOVE.L  #Cblurb,D2          ; Move the message to D2
  865.         MOVE.L  #SIZECBlurb,D3      ; Move the size of the message to D3
  866.         CALLDOS Write               ; Macro write to file
  867.         MOVE.L  #Cstart,D4          ; Move startline to D4
  868.         MOVE.L  #Cend,D5            ; Move endline to D5
  869.         MOVE.L  #SIZECstart,D6      ; Size of startline to D6
  870.         MOVE.L  #SIZECend,D7        ; Size of endline to D7
  871.  
  872. Primeloop:
  873.  
  874. ; The reading and writing of the files now takes place.  Firstly, the loop
  875. ; should be "primed", just in case the first character is a dud (e.g. if
  876. ; the infile is empty (in which case all the user gets is an outfile
  877. ; containing the blurb message we wrote above).
  878.                                      
  879.         MOVE.L  Infilehd,D1         ; Move infile handle into D1
  880.         MOVE.L  #Infilechar,D2      ; Move the Infilechar buffer to D2
  881.         MOVE.L  #$01,D3             ; Reading just one byte
  882.         CALLDOS Read                ; Macro calls function
  883.         TST.B   D0                  ; Read OK
  884.         BEQ     Closefiles          ; No! Close all files
  885.         CMP.B   #LF,Infilechar      ; Was character a linefeed?
  886.         BEQ     1$                  ; Yes! Go startline and endline
  887.         CMP.B   #CR,Infilechar      ; Was character a carriage return?
  888.         BEQ     1$                  ; Yes! Go startline and endline
  889.         BSR     Startline           ; Write the start of the line
  890.         BSR     WriteChar           ; Then write the character  
  891.         BRA     ReadChar            ; Branch to Read the next char
  892. 1$      BSR     Startline           ; Write the start of the line
  893.         BRA     Endline             ; Go endline ->
  894.  
  895. ReadChar:
  896.  
  897. ; This is the top of the loop that does all the work.
  898.  
  899.         MOVE.L  Infilehd,D1         ; Move infile handle into D1
  900.         MOVE.L  #Infilechar,D2      ; The buffer for the character
  901.         MOVE.L  #$01,D3             ; Just one byte to read
  902.         CALLDOS Read                ; Macro calls function
  903.         TST.B   D0                  ; Any Problems?
  904.         BEQ     LastChar            ; Yes!  Head off to finish up ->
  905.         CMP.B   #Apost,Infilechar   ; else check if character was '
  906.         BNE     1$                  ; No!  Next ->
  907.         CMP.B   #$02,Optionflag     ; Are we in Pascal mode?
  908.         BNE     1$                  ; No!  Next ->
  909.         MOVE.L  Outfilehd,D1        ; ...else load outfile handle...
  910.         MOVE.L  #Apostrophe,D2      ; ...load an apostrophe string...
  911.         MOVE.L  #$01,D3             ; ...just the one thanx!
  912.         CALLDOS Write               ; Macro calls function
  913. 1$      CMP.B   #LF,Infilechar      ; Was the character a linefeed?
  914.         BEQ     Endline             ; Yes!  Head off ->
  915.         CMP.B   #CR,Infilechar      ; Was the character a carriage return?
  916.         BEQ     Endline             ; Yes!  Head off ->
  917.         BSR     WriteChar           ; After those checks, write ->
  918.         BRA     ReadChar            ; Back to start of loop
  919.  
  920. Endline:
  921.  
  922. ; This bit of code is called when a linefeed or carriage return is read,
  923. ; thus signalling the end of a line. 
  924.  
  925.         MOVE.L  Outfilehd,D1        ; Load the outfile handle
  926.         MOVE.L  D5,D2               ; Load the end option stored in D5
  927.         MOVE.L  D7,D3               ; Load the length of the end option
  928.         CALLDOS Write               ; Macro calls function
  929.         BSR     Startline           ; Start the next line
  930.         BRA     ReadChar            ; Loop again!
  931.  
  932. LastChar:
  933.  
  934. ; If there was a problem reading the file, I'm assuming we're finished,
  935. ; and so we need to firstly finish the line.
  936.  
  937.         MOVE.L  Outfilehd,D1        ; Load the outfile handle
  938.         MOVE.L  D5,D2               ; Load the end option stored in D5
  939.         MOVE.L  D7,D3               ; Load the length of the end option
  940.         CALLDOS Write               ; Macro calls function
  941.  
  942. Closefiles:
  943.  
  944. ; After closing off the last line, we need to close the open files.
  945.  
  946.         MOVE.L  Infilehd,D1         ; Load the infile handle
  947.         CALLDOS Close               ; Macro calls function
  948.         MOVE.L  Outfilehd,D1        ; Load the outfile handle
  949.         CALLDOS Close               ; Macro calls function
  950.  
  951. LastMessage:
  952.  
  953. ; The last stage of the program is to notify the user that all operations
  954. ; have ceased.
  955.  
  956.         LEA     AllOk,A1            ; Load the final message into A1
  957.         MOVE.L  Winhd,A0            ; Move window handle into a0
  958.         LEA     Screentitle,A2      ; Load the screen title into a2
  959.         CALLINT Setwindowtitles     ; Macro changes screen title
  960.         MOVE.L  #$00,A0             ; All screens to beep!
  961.         CALLINT DisplayBeep         ; Beep the display to wake up user
  962.         MOVE.L  #$46,D1             ; Delay closing by 1.4 seconds(!)
  963.         CALLDOS Delay               ; Macro calls function
  964.         BRA     Cleanup             ; finito and gone ->
  965.  
  966. ErrorMessage:
  967.  
  968.         MOVE.L  Winhd,A0            ; Move window handle into a0
  969.         LEA     Screentitle,A2      ; Load the screen title into a2
  970.         CALLINT Setwindowtitles     ; Macro changes screen title
  971.         BRA     Mainloop            ; Back to the mainloop ->
  972.  
  973. *********************************************************************
  974. *                                                                   *
  975. * Subroutines                                                       *
  976. * -----------                                                       *
  977. *                                                                   *
  978. * These sections of code are either re-used several times, or are   *
  979. * just easy to put somewhere at the end of the program where no-one *
  980. * will mind too much!                                               *
  981. *                                                                   *
  982. *********************************************************************
  983.  
  984. Openint:
  985.  
  986. ; The opening of the intuition library, including an error branch if things
  987. ; don't go according to plan!
  988.  
  989.         LEA      Intname,A1         ; Load intuition library into a1
  990.         EXEC     Openlibrary        ; Macro opens library
  991.         BEQ      Exittodos          ; If it doesn't open, we quit
  992.         MOVE.L   D0,_intuitionbase  ; Save the return address
  993.         RTS                         ; ...and back at you ->
  994.  
  995. Opendos:
  996.  
  997. ; The opening of the dos library, including an error branch if things
  998. ; don't go according to plan!
  999.  
  1000.         LEA      Dosname,A1         ; Load dos library into a1
  1001.         MOVE.L   #$00,D0            ; Any version will do
  1002.         EXEC     Openlibrary        ; Macro opens library
  1003.         BEQ      NoDos              ; If there's a problem, close down
  1004.         MOVE.L   D0,_dosbase        ; Save the return address
  1005.         RTS                         ; ...and back at you ->
  1006.  
  1007. NoDos:
  1008.  
  1009. ; If dos fails to open, we need to close intuition.
  1010.  
  1011.         BSR     Closeint            ; Jump to close intuition subroutine
  1012.         BRA     Exittodos           ; Then off!
  1013.  
  1014. Win:
  1015.  
  1016. ; This little bit opens the second window.
  1017.  
  1018.         LEA     Win_defs,A0        ; Load window definitions to a0
  1019.         BSR     Openwin             ; Open the window
  1020.         RTS                         ; ...and back at you ->
  1021.  
  1022. Marketing_Win:
  1023.  
  1024. ; Here the title is drawn, and the screen title changed.
  1025.  
  1026.         BSR     Drawtitle           ; Draw title on window
  1027.         BSR     Changetitle         ; Alter screen title
  1028.         RTS                         ; ...and back at you ->
  1029.  
  1030. Waitformess:
  1031.  
  1032. ; Rather than check all the time if the window has spoken to intuition,
  1033. ; we use the userport of the window structure to wait for a message
  1034. ; before doing anything else.  Low maintenance!
  1035.  
  1036.         MOVE.L   Winhd,A0           ; Move window handle into a0
  1037.         MOVE.L   Wd_userport(A0),A0 ; UserPort offset at byte 86
  1038.         EXEC     Waitport           ; Macro waits for message from window
  1039.         RTS                         ; ...and back at you ->
  1040.  
  1041. Drawtitle:
  1042.  
  1043. ; This loads the image data, the x and y offsets for the image on the
  1044. ; window, and then draws the title onto the window.
  1045.  
  1046.         MOVE.L  Winhd,A0            ; Move window handle into a0
  1047.         MOVE.L  Wd_rport(A0),A0     ; RastPort offset found at byte 50
  1048.         MOVE.L  #$17,D0             ; x-offset in window loaded to d0
  1049.         MOVE.L  #$0D,D1             ; y-offset in window loaded to d1
  1050.         LEA     Title,A1            ; Load image data to a1
  1051.         CALLINT Drawimage           ; Macro draws image
  1052.         RTS                         ; ...and back at you ->
  1053.  
  1054. Changetitle:
  1055.  
  1056. ; Here we change the workbench screen title.
  1057.  
  1058.         MOVE.L  Winhd,A0           ; Move window handle into a0
  1059.         MOVEA.L #-1,A1             ; Move current window title into a1
  1060.         LEA     Screentitle,A2     ; Load the screen title into a2
  1061.         CALLINT Setwindowtitles    ; Macro changes screen title
  1062.         RTS                        ; ...and back at you ->
  1063.  
  1064. Openwin:
  1065.  
  1066. ; Just calls the function and stores the window handle.
  1067.  
  1068.         CALLINT Openwindow          ; Macro opens window
  1069.         MOVE.L  D0,Winhd            ; Save return address (window handle)
  1070.         RTS                         ; ...and back at you ->
  1071.  
  1072. Startline:
  1073.  
  1074. ; Called when we need to write the "echo", "writeln" or "printf" commands.
  1075.  
  1076.         MOVE.L  Outfilehd,D1        ; Load the outfile handle
  1077.         MOVE.L  D4,D2               ; Load the end option stored in D2
  1078.         MOVE.L  D6,D3               ; Load the length of the end option
  1079.         CALLDOS Write               ; Macro calls function
  1080.         RTS                         ; ...and back at you ->
  1081.  
  1082. WriteChar:
  1083.  
  1084. ; If all has gone well, we can write the character into the outfile.
  1085.  
  1086.         MOVE.L  Outfilehd,D1        ; Load the outfile handle
  1087.         MOVE.L  #Infilechar,D2      ; Load the character buffer
  1088.         MOVE.L  #$01,D3             ; Just the one!
  1089.         CALLDOS Write               ; Macro calls function
  1090.         RTS                         ; ...and back at you ->
  1091.  
  1092. ClearBuff:
  1093.  
  1094. ; Here we clear memory buffers
  1095.  
  1096. 1$      SUBQ.B    #$01,D0             ; Subtract one from counter
  1097.     MOVE.B  #$00,(A0)+          ; Move a dud into buffer
  1098.     CMPI.B    #$00,D0             ; Are we at zero yet?
  1099.     BNE    1$                  ; No, so go back...
  1100.         RTS                         ; outta here ->
  1101.         
  1102. Cleanup:
  1103.  
  1104. ; Finally it's over, but before we can go home we need to do some quick
  1105. ; housekeeping!
  1106.  
  1107.         CMP.L   #$00,_ARPbase       ; Is ARP open?
  1108.         BEQ     1$                  ; No...then move on...
  1109.         BSR     Closearp            ; ...else close arp
  1110. 1$      BSR     Closewin            ; Close window
  1111.         BSR     Closedos            ; Close dos
  1112.         BSR     Closeint            ; Close intuition
  1113.     RTS
  1114.  
  1115. Closewin:
  1116.  
  1117. ; Closes the window.
  1118.  
  1119.         MOVE.L  Winhd,A0            ; Move window handle into a0
  1120.         CALLINT Closewindow         ; Macro closes window down
  1121.         RTS                         ; ...and back at you ->
  1122.  
  1123. Closedos:
  1124.  
  1125. ; Closes the dos library.
  1126.  
  1127.         MOVE.L   _dosbase,A1        ; Move dos base into a1
  1128.         EXEC     Closelibrary       ; Macro closes dos
  1129.         RTS                         ; ...and back at you ->
  1130.  
  1131. Closeint:
  1132.  
  1133. ; Closes the intuition library.
  1134.  
  1135.         MOVE.L   _intuitionbase,A1  ; Move intuition base into a1
  1136.         EXEC     Closelibrary       ; Macro closes intuition
  1137.         RTS                         ; ...and back at you ->
  1138.  
  1139. Closearp:
  1140.  
  1141. ; Closes the arp library.
  1142.  
  1143.         MOVE.L   _ARPbase,A1        ; Move arp base into a1
  1144.         EXEC     Closelibrary       ; Macro closes arp
  1145.         RTS                         ; ...and back at you ->
  1146.  
  1147. *********************************************************************
  1148. *                                                                   *
  1149. * Structures and Memory Allocation                                  *
  1150. * --------------------------------                                  *
  1151. *                                                                   *
  1152. * Here are the definitions held for the structures used in the      *
  1153. * program, as well as memory blocks Set aside for definitions such  *
  1154. * as the messages.                                                  *
  1155. *                                                                   *
  1156. *********************************************************************
  1157.     
  1158. Win_defs:
  1159.  
  1160. ; Window structure
  1161.  
  1162.         DC.W    $C2                ; x-offset on screen
  1163.         DC.W    $32                ; y-offset on screen
  1164.         DC.W    $F6                ; window width
  1165.         DC.W    $8C                ; window height
  1166.         DC.B    $01                ; print colour
  1167.         DC.B    $03                ; background colour
  1168.         DC.L    $00000240          ; IDCMP flags: CLOSEWINDOW|GADGETDOWN
  1169.         DC.L    $0000100e          ; ACTIVATE|WINDOWDRAG|WINDOWDEPTH
  1170.                                    ; WINDOWCLOSE
  1171.         DC.L    Gadgenerate        ; First Gadget 
  1172.         DC.L    $00                ; Standard Checkmark
  1173.         DC.L    Winname            ; Window name 
  1174.         DC.L    $00                ; screen pointer
  1175.         DC.L    $00                ; no custom bitmap
  1176.         DC.W    $00,$00,$00,$00    ; intuition sets these given that...
  1177.         DC.W    $01                ; this is a WORKBENCH screen 
  1178.  
  1179. Gadgenerate:
  1180.  
  1181. ; Gadget structure
  1182.  
  1183.         DC.L    Gadscript          ; next gadget
  1184.         DC.W    $8C                ; x-offset on window
  1185.         DC.W    $76                ; y-offset on window
  1186.         DC.W    $59                ; gadget width
  1187.         DC.W    $0C                ; gadget height
  1188.         DC.W    $04                ; Alternative Image type
  1189.         DC.W    $01                ; RELVERIFY
  1190.         DC.W    $01                ; BOOLEAN
  1191.         DC.L    Generate           ; Data for picture of gadget
  1192.         DC.L    $00                ; Alternative image
  1193.         DC.L    $00                ; no text around gadget
  1194.         DC.L    $00,$00            ; no exclude,no special info
  1195.         DC.W    $01                ; Gadget Identification
  1196.         DC.L    $00                ; no User Data
  1197.  
  1198. Gadscript:
  1199.  
  1200. ; Gadget structure
  1201.  
  1202.         DC.L    Gadpascal          ; next gadget
  1203.         DC.W    $19                ; x-offset on window
  1204.         DC.W    $61                ; y-offset on window
  1205.         DC.W    $11                ; gadget width
  1206.         DC.W    $09                ; gadget height
  1207.         DC.W    $06                ; Inverted gadget
  1208.         DC.W    $0101              ; TOGGLESELECT|RELVERIFY
  1209.         DC.W    $01                ; BOOLEAN
  1210.         DC.L    Buttonoff          ; Data for picture of gadget
  1211.         DC.L    Buttonon           ; Alternative image
  1212.         DC.L    Scripttxt          ; text around gadget
  1213.         DC.L    $00                ; no mutual exclude
  1214.         DC.L    $00                ; no special info
  1215.         DC.W    $02                ; Gadget Identification
  1216.         DC.L    $00                ; no User Data
  1217.  
  1218. Gadpascal:
  1219.  
  1220. ; Gadget structure
  1221.  
  1222.         DC.L    Gadc               ; next gadget
  1223.         DC.W    $19                ; x-offset on window
  1224.         DC.W    $6D                ; y-offset on window
  1225.         DC.W    $11                ; gadget width
  1226.         DC.W    $09                ; gadget height
  1227.         DC.W    $06                ; Alternative Image type
  1228.         DC.W    $0101              ; TOGGLESELECT|RELVERIFY
  1229.         DC.W    $01                ; BOOLEAN
  1230.         DC.L    Buttonoff          ; Data for picture of gadget
  1231.         DC.L    Buttonon           ; Alternative image
  1232.         DC.L    Pascaltxt          ; text around gadget
  1233.         DC.L    $00                ; no mutual exclude
  1234.         DC.L    $00                ; no special info
  1235.         DC.W    $03                ; Gadget Identification
  1236.         DC.L    $00                ; no User Data
  1237.  
  1238. Gadc:
  1239.  
  1240. ; Gadget structure
  1241.  
  1242.         DC.L    Gadinfile          ; next gadget
  1243.         DC.W    $19                ; x-offset on window
  1244.         DC.W    $79                ; y-offset on window
  1245.         DC.W    $11                ; gadget width
  1246.         DC.W    $09                ; gadget height
  1247.         DC.W    $06                ; Alternative Image type
  1248.         DC.W    $0101              ; TOGGLESELECT|RELVERIFY
  1249.         DC.W    $01                ; BOOLEAN
  1250.         DC.L    Buttonoff          ; Data for picture of gadget
  1251.         DC.L    Buttonon           ; Alternative image
  1252.         DC.L    Ctxt               ; text around gadget
  1253.         DC.L    $00                ; no mutual exclude
  1254.         DC.L    $00                ; no special info
  1255.         DC.W    $04                ; Gadget Identification
  1256.         DC.L    $00                ; no User Data
  1257.  
  1258. Gadinfile:
  1259.  
  1260. ; Gadget structure
  1261.  
  1262.         DC.L    Gadoutfile         ; next gadget
  1263.         DC.W    $38                ; x-offset on window
  1264.         DC.W    $40                ; y-offset on window
  1265.         DC.W    $69                ; gadget width
  1266.         DC.W    $0E                ; gadget height
  1267.         DC.W    $04                ; Inverted Image type
  1268.         DC.W    $01                ; RELVERIFY
  1269.         DC.W    $04                ; STRING
  1270.         DC.L    File               ; Data for picture of gadget
  1271.         DC.L    $00                ; Alternative image
  1272.         DC.L    Infiletxt          ; text around gadget
  1273.         DC.L    $00                ; no mutual exclude
  1274.         DC.L    Infileinfo         ; special string info
  1275.         DC.W    $05                ; Gadget Identification
  1276.         DC.L    $00                ; no User Data
  1277.  
  1278. Gadoutfile:
  1279.  
  1280. ; Gadget structure
  1281.  
  1282.         DC.L    0                  ; no next gadget
  1283.         DC.W    $38                ; x-offset on window
  1284.         DC.W    $52                ; y-offset on window
  1285.         DC.W    $69                ; gadget width
  1286.         DC.W    $0E                ; gadget height
  1287.         DC.W    $04                ; Inverted Image type
  1288.         DC.W    $01                ; RELVERIFY
  1289.         DC.W    $04                ; STRING
  1290.         DC.L    File               ; Data for picture of gadget
  1291.         DC.L    $00                ; Alternative image
  1292.         DC.L    Outfiletxt         ; text around gadget
  1293.         DC.L    $00                ; no mutual exclude
  1294.         DC.L    Outfileinfo        ; special string info
  1295.         DC.W    $06                ; Gadget Identification
  1296.         DC.L    $00                ; no User Data
  1297.  
  1298. Inreq:
  1299.  
  1300. ; Gadget structure
  1301.  
  1302.         DC.L    Outreq             ; next gadget
  1303.         DC.W    $18                ; x-offset on window
  1304.         DC.W    $3D                ; y-offset on window
  1305.         DC.W    $14                ; gadget width
  1306.         DC.W    $0E                ; gadget height
  1307.         DC.W    $04                ; Inverted Image type
  1308.         DC.W    $01                ; RELVERIFY
  1309.         DC.W    $01                ; BOOLEAN
  1310.         DC.L    FReq               ; Data for picture of gadget
  1311.         DC.L    $00                ; no other image
  1312.         DC.L    $00                ; no text around gadget
  1313.         DC.L    $00,$00            ; no exclude,no special info
  1314.         DC.W    $07                ; Gadget Identification
  1315.         DC.L    $00                ; no User Data
  1316.  
  1317. Outreq:
  1318.  
  1319. ; Gadget structure
  1320.  
  1321.         DC.L    $00                ; no more gadgets for this window
  1322.         DC.W    $18                ; x-offset on window
  1323.         DC.W    $4F                ; y-offset on window
  1324.         DC.W    $14                ; gadget width
  1325.         DC.W    $0E                ; gadget height
  1326.         DC.W    $04                ; Inverted Image type
  1327.         DC.W    $01                ; RELVERIFY
  1328.         DC.W    $01                ; BOOLEAN
  1329.         DC.L    FReq               ; Data for picture of gadget
  1330.         DC.L    $00                ; no other image
  1331.         DC.L    $00                ; no text around gadget
  1332.         DC.L    $00,$00            ; no exclude,no special info
  1333.         DC.W    $08                ; Gadget Identification
  1334.         DC.L    $00                ; no User Data
  1335.  
  1336. Scripttxt:
  1337.  
  1338. ; Intuitext structure
  1339.  
  1340.         DC.B    $02,$00,$01        ; FrontPen,BackPen,DrawMode
  1341.  
  1342.         Even                       ; Fill to make even address for word
  1343.  
  1344.         DC.W    $19,$01            ; Left edge, top edge
  1345.         DC.L    $00                ; No special font
  1346.         DC.L    Scriptx            ; The actual text
  1347.         DC.L    $00                ; No next text (try saying that fast!)
  1348.  
  1349. Pascaltxt:
  1350.  
  1351. ; Intuitext structure
  1352.  
  1353.         DC.B    $02,$00,$01        ; FrontPen,BackPen,DrawMode
  1354.  
  1355.         Even                       ; Fill to make even address for word
  1356.  
  1357.         DC.W    $19,$01            ; Left edge, top edge
  1358.         DC.L    $00                ; No special font
  1359.         DC.L    Pascaltx           ; The actual text
  1360.         DC.L    $00                ; No next text 
  1361.  
  1362. Ctxt:
  1363.  
  1364. ; Intuitext structure
  1365.  
  1366.         DC.B    $02,$00,$01        ; FrontPen,BackPen,DrawMode
  1367.  
  1368.         Even                       ; Fill to make even address for word
  1369.  
  1370.         DC.W    $19,$01            ; Left edge, top edge
  1371.         DC.L    $00                ; No special font
  1372.         DC.L    Ctx                ; The actual text
  1373.         DC.L    $00                ; No next text 
  1374.  
  1375. Infiletxt:
  1376.  
  1377. ; Intuitext structure
  1378.  
  1379.         DC.B    $03,$00,$01        ; FrontPen,BackPen,DrawMode
  1380.  
  1381.         Even                       ; Fill to make even address for word
  1382.  
  1383.         DC.W    $73,$01            ; Left edge, top edge
  1384.         DC.L    $00                ; No special font
  1385.         DC.L    Infiletx           ; The actual text
  1386.         DC.L    $00                ; No next text 
  1387.  
  1388. Outfiletxt:
  1389.  
  1390. ; Intuitext structure
  1391.  
  1392.         DC.B    $03,$00,$01        ; FrontPen,BackPen,DrawMode
  1393.  
  1394.         Even                       ; Fill to make even address for word
  1395.  
  1396.         DC.W    $73,$01            ; Left edge, top edge
  1397.         DC.L    $00                ; No special font
  1398.         DC.L    Outfiletx          ; The actual text
  1399.         DC.L    $00                ; No next text 
  1400.  
  1401. Atext:
  1402.  
  1403. ; Intuitext structure
  1404.  
  1405.         DC.B    $02,$01,$01        ; FrontPen,BackPen,DrawMode
  1406.  
  1407.         Even                       ; Fill to make even address for word
  1408.  
  1409.         DC.W    $0D,$08            ; Left edge, top edge
  1410.         DC.L    $00                ; No special font
  1411.         DC.L    Atx                ; The actual text
  1412.         DC.L    $00                ; No next text
  1413.  
  1414. Ltext:
  1415.  
  1416. ; Intuitext structure
  1417.  
  1418.         DC.B    $02,$01,$01        ; FrontPen,BackPen,DrawMode
  1419.  
  1420.         Even                       ; Fill to make even address for word
  1421.  
  1422.         DC.W    $06,$03            ; Left edge, top edge
  1423.         DC.L    $00                ; No special font
  1424.         DC.L    Ltx                ; The actual text
  1425.         DC.L    $00                ; No next text 
  1426.  
  1427. Rtext:
  1428.  
  1429. ; Intuitext structure
  1430.  
  1431.         DC.B    $02,$01,$01        ; FrontPen,BackPen,DrawMode
  1432.  
  1433.         Even                       ; Fill to make even address for word
  1434.  
  1435.         DC.W    $06,$03            ; Left edge, top edge
  1436.         DC.L    $00                ; No special font
  1437.         DC.L    Rtx                ; The actual text
  1438.         DC.L    $00                ; No next text 
  1439.  
  1440. Infileinfo:
  1441.  
  1442. ; Stringinfo structure
  1443.  
  1444.         DC.L    Infilebuff         ; Buffer for input text
  1445.         DC.L    Undobuff           ; Buffer for undo function (Amiga-Q)
  1446.         DC.W    $00                ; Buffer start position
  1447.         DC.W    $64                ; Number of characters
  1448.         DC.W    $00,$00,$00        ; DispPos,UndoPos,NumChars
  1449.         DC.W    $00,$00,$00        ; DispCount,CLeft,CTop
  1450.         DC.L    $00,$00,$00        ; Layer,LongInt,Keymap
  1451.  
  1452. Outfileinfo:
  1453.  
  1454. ; Stringinfo structure
  1455.  
  1456.         DC.L    Outfilebuff        ; Buffer for input text
  1457.         DC.L    Undobuff           ; Buffer for undo function (Amiga-Q)
  1458.         DC.W    $00                ; Buffer start position
  1459.         DC.W    $64                ; Number of characters
  1460.         DC.W    $00,$00,$00        ; DispPos,UndoPos,NumChars
  1461.         DC.W    $00,$00,$00        ; DispCount,CLeft,CTop
  1462.         DC.L    $00,$00,$00        ; Layer,LongInt,Keymap
  1463.  
  1464. Arpfrequest:
  1465.  
  1466. ; ARP requester structure.  I had tonnes of trouble with this one, and
  1467. ; I'd like to thank George Knight, and his article on ARP requesters 
  1468. ; from Megadisc #30B for assistance.  I'm still not too sure, so the
  1469. ; structure explanations are brief.  Good Luck!
  1470.  
  1471.         DC.L    Winname            ; Window name
  1472.         DC.L    ArpFileBuff        ; buffer for file information
  1473.         DC.L    ArpDirBuff         ; buffer for dir information
  1474.         DC.L    0                  ; Window or NULL
  1475.         DC.B    40                 ; Function Flags
  1476.         DC.B    0                  ; Reserved - set to NULL
  1477.         DC.L    0                  ; Func to call for wildcards
  1478.         DC.L    0                  ; RESERVED
  1479.  
  1480. ; Memory allocations
  1481.  
  1482. _ARPbase:       DS.L    $01        ; memory for arp base
  1483. _intuitionbase: DS.L    $01        ; memory for intuition base
  1484. _dosbase:       DS.L    $01        ; memory for dos base
  1485. _reqbase:       DS.L    $01        ; memory for req base
  1486. Winhd:          DS.L    $01        ; memory for window handle
  1487. Infilehd:       DS.L    $01        ; memory for infile handle
  1488. Outfilehd:      DS.L    $01        ; memory for outfile handle
  1489. Message:        DS.L    $01        ; memory for return message
  1490. Returnmsg:      DS.L    $01        ; memory for WB return message
  1491. Infilechar:     DS.B    $01        ; memory for one infile character
  1492. Infilebuff:     DS.B    $64        ; memory for name of infile
  1493. Outfilebuff:    DS.B    $64        ; memory for name of outfile
  1494. Undobuff:       DS.B    $64        ; memory for undo
  1495. ArpFileBuff:    DS.B    $1E        ; memory for File (from ARP requester)
  1496. ArpDirBuff:     DS.B    $46        ; memory for Dir (from ARP requester)
  1497. Optionflag:     DC.B    $00        ; memory for option flag
  1498. IsArpOpen:      DC.B    $00        ; memory for Requester flag
  1499.  
  1500. ;       Script text
  1501.         
  1502. Scriptx:        DC.B    "Script",$00
  1503. Scstart:        DC.B    "echo ",$22
  1504. SIZEScstart:    =       *-Scstart  ; current address minus the last label
  1505. Scend:          DC.B    $22,LF     
  1506. SIZEScend:      =       *-Scend    ; current address minus the last label
  1507. Scblurb:        DC.B    LF,"; Courtesy of ADDTEXT - A N Peck (1995)",LF,LF
  1508. SIZEScBlurb:    =       *-Scblurb  ; current address minus the last label
  1509.  
  1510. ;       Pascal text
  1511.  
  1512. Pascaltx:       DC.B    "Pascal",$00
  1513. Passtart:       DC.B    "Writeln (",Apost
  1514. SIZEPasstart:   =       *-Passtart ; current address minus the last label
  1515. Pasend:         DC.B    Apost,$29,$3B,LF
  1516. SIZEPasend:     =       *-Pasend   ; current address minus the last label
  1517. Pasblurb:       DC.B    LF,"{ Courtesy of ADDTEXT - A N Peck (1995) }",LF,LF
  1518. SIZEPasBlurb:   =       *-Pasblurb ; current address minus the last label
  1519.  
  1520. ;       C text
  1521.  
  1522. Ctx:            DC.B    "C",$00
  1523. Cstart:         DC.B    "Printf (",$22
  1524. SIZECstart:     =       *-Cstart   ; current address minus the last label
  1525. Cend:           DC.B    $5C,$6E,$22,$29,$3B,LF
  1526. SIZECend:       =       *-Cend     ; current address minus the last label
  1527. Cblurb:         DC.B    LF,"/* Courtesy of ADDTEXT - A N Peck (1995) */",LF,LF
  1528. SIZECBlurb:     =       *-Cblurb   ; current address minus the last label
  1529.  
  1530. ;       Other text
  1531.  
  1532. Infiletx:       DC.B    "Infile",$00
  1533. Outfiletx:      DC.B    "Outfile",$00
  1534. Atx:            DC.B    "Copy over old file?",$00
  1535. Ltx:            DC.B    "No",$00
  1536. Rtx:            DC.B    "Yes",$00
  1537. Winname:        DC.B    "Your choice:",$00 
  1538. Screentitle:    DC.B    "FREEWARE - 1995",$00
  1539. BigPath:        DC.B    "Path too long!",$00
  1540. NoInfile:       DC.B    "Select Infile!",$00
  1541. NoOutfile:      DC.B    "Select Outfile!",$00
  1542. NoOption:       DC.B    "Select Option!",$00
  1543. NoInfileAcc:    DC.B    "Can",Apost,"t access Infile!",$00
  1544. NoOutfileAcc:   DC.B    "Can",Apost,"t open Outfile!",$00 
  1545. Apostrophe:     DC.B    Apost,$00
  1546. Working:        DC.B    "Working...",$00
  1547. AllOk:          DC.B    "Finished!  Bye...",$00
  1548. Intname:        DC.B    "intuition.library",$00  ; intuition library name
  1549. Dosname:        DC.B    "dos.library",$00        ; dos library name
  1550. Arpname:        DC.B    "arp.library",$00        ; arp library name
  1551. Aslname:        DC.B    "asl.library",$00        ; arp library name
  1552.  
  1553. *********************************************************************
  1554. *                                                                   *
  1555. * Data                                                              *
  1556. * ----                                                              *
  1557. *                                                                   *
  1558. * Here are the images used, all converted by the wonderful program  *
  1559. * Convbrush by David Kinder.  There are various other similar       *
  1560. * utilities, but I like this one because it was written in Pascal!  *
  1561. * Using such images blows out the size of the executable a bit, but *
  1562. * gosh it looks pretty!                                             *
  1563. *                                                                   *
  1564. *********************************************************************
  1565.  
  1566.         Section Image,Data_C
  1567.  
  1568. Title           DC.W    0,0,189,41,2
  1569.                 DC.L    Titledat
  1570.                 DC.B    3,0
  1571.                 DC.L    0
  1572. Titledat        DC.W    32767,65535,65535,65535,65535,65535,65535,65535
  1573.                 DC.W    65535,65535,65535,65520,65535,65535,65535,65535
  1574.                 DC.W    65535,65535,65535,65535,65535,65535,65535,65528
  1575.                 DC.W    65535,65535,65535,65535,65535,65535,65535,65535
  1576.                 DC.W    65535,65535,65535,65528,57344,00000,00000,00000
  1577.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00056
  1578.                 DC.W    57344,00000,00000,00000,00000,00000,00000,00000
  1579.                 DC.W    00000,00000,00000,00056,57344,03871,61431,65535
  1580.                 DC.W    65535,49344,36979,52880,00000,00000,00000,00056
  1581.                 DC.W    57344,08127,65535,65535,65535,57633,26764,12648
  1582.                 DC.W    00000,00000,00000,00056,57344,08127,65535,65535
  1583.                 DC.W    65535,58065,10421,61264,00000,00000,00000,00056
  1584.                 DC.W    57344,08159,65535,65535,65535,58065,18612,43296
  1585.                 DC.W    00000,00000,00000,00056,57344,16351,65535,65535
  1586.                 DC.W    65535,57873,26765,61264,00000,00000,00000,00056
  1587.                 DC.W    57344,16351,65535,65535,65535,58065,26804,12648
  1588.                 DC.W    00000,00000,00000,00056,57344,16351,65535,64511
  1589.                 DC.W    65215,16672,36931,52880,00000,00000,00000,00056
  1590.                 DC.W    57344,16383,65535,64510,64575,00000,00000,00000
  1591.                 DC.W    00000,00000,00000,00056,57344,16383,65535,64510
  1592.                 DC.W    65087,00198,01100,58145,10243,47104,00000,00056
  1593.                 DC.W    57344,32767,65535,64510,65087,00297,02739,05330
  1594.                 DC.W    54276,17408,00000,00056,57344,32767,65535,64511
  1595.                 DC.W    65343,00726,35757,27474,54283,43008,00000,00056
  1596.                 DC.W    57344,32767,65535,64511,65343,00553,02733,06994
  1597.                 DC.W    54276,43008,00000,00056,57344,32767,65535,64511
  1598.                 DC.W    65471,00726,35117,22622,55047,26624,00000,00056
  1599.                 DC.W    57344,32767,65535,64511,65471,00297,02739,27459
  1600.                 DC.W    12424,43008,00000,00056,57344,65535,65535,65535
  1601.                 DC.W    65535,32966,01100,38076,52999,04096,00000,00056
  1602.                 DC.W    57344,65535,65531,65535,65535,32768,00000,00000
  1603.                 DC.W    00000,00000,00000,00056,57344,32767,61425,64511
  1604.                 DC.W    65471,00275,14536,39207,12312,60942,12560,00056
  1605.                 DC.W    57344,00000,00000,00000,00000,00684,50485,26328
  1606.                 DC.W    51237,04369,19112,00056,57344,00000,00000,00000
  1607.                 DC.W    00000,00747,23250,23127,46170,59918,46280,00056
  1608.                 DC.W    57344,00000,00000,00000,00000,00683,18133,23188
  1609.                 DC.W    46170,35337,35496,00056,57344,00000,00000,00000
  1610.                 DC.W    00000,00584,22039,17110,33858,59927,46760,00056
  1611.                 DC.W    57344,00151,00256,08191,65472,00683,23253,23256
  1612.                 DC.W    46171,06672,52292,00056,57344,00511,33664,04607
  1613.                 DC.W    08128,00276,42280,42279,18468,58383,13240,00056
  1614.                 DC.W    57344,00511,51072,07934,61376,00000,00000,00000
  1615.                 DC.W    00000,00000,00000,00056,57344,00511,33664,08191
  1616.                 DC.W    65472,00201,15288,51315,00000,00000,00000,00056
  1617.                 DC.W    57344,00255,37760,08123,64448,00310,50245,13452
  1618.                 DC.W    32768,00000,00000,00056,57344,00255,65472,08135
  1619.                 DC.W    64576,00726,47834,54363,16384,00000,00000,00056
  1620.                 DC.W    57344,00103,37760,08191,65472,00726,51910,54363
  1621.                 DC.W    16384,00000,00000,00056,57344,00000,00000,00000
  1622.                 DC.W    00000,00534,63190,05976,16384,00000,00000,00056
  1623.                 DC.W    57344,00000,00000,00000,00000,00729,35546,53387
  1624.                 DC.W    16384,00000,00000,00056,57344,00000,00000,00000
  1625.                 DC.W    00000,00294,28965,12148,32768,00000,00000,00056
  1626.                 DC.W    57344,00000,00000,00000,00000,00000,00000,00000
  1627.                 DC.W    00000,00000,00000,00056,57344,00000,00000,00000
  1628.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00056
  1629.                 DC.W    65535,65535,65535,65535,65535,65535,65535,65535
  1630.                 DC.W    65535,65535,65535,65528,65535,65535,65535,65535
  1631.                 DC.W    65535,65535,65535,65535,65535,65535,65535,65528
  1632.                 DC.W    32767,65535,65535,65535,65535,65535,65535,65535
  1633.                 DC.W    65535,65535,65535,65520
  1634.                 DC.W    32767,65535,65535,65535,65535,65535,65535,65535
  1635.                 DC.W    65535,65535,65535,65520,40960,00000,00000,00000
  1636.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00040
  1637.                 DC.W    49151,65535,65535,65535,65535,65535,65535,65535
  1638.                 DC.W    65535,65535,65535,65512,40960,00000,00000,00000
  1639.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00040
  1640.                 DC.W    40960,00000,00000,00000,00000,00000,00000,00000
  1641.                 DC.W    00000,00000,00000,00040,40960,00000,00000,00000
  1642.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00040
  1643.                 DC.W    40960,03103,36807,64507,52991,00192,36979,52880
  1644.                 DC.W    00000,00000,00000,00040,40960,03084,50790,55705
  1645.                 DC.W    36059,00288,53322,04256,00000,00000,00000,00040
  1646.                 DC.W    40960,03596,26164,51593,34969,00288,45131,04288
  1647.                 DC.W    00000,00000,00000,00040,40960,05644,26164,51592
  1648.                 DC.W    53401,00480,36978,04256,00000,00000,00000,00040
  1649.                 DC.W    40960,05644,26160,49536,53272,00288,36931,52880
  1650.                 DC.W    00000,00000,00000,00040,40960,05644,26160,49552
  1651.                 DC.W    24600,00000,00000,00000,00000,00000,00000,00040
  1652.                 DC.W    40960,04876,26160,49648,24600,00000,00000,00000
  1653.                 DC.W    00000,00000,00000,00040,40960,04876,26160,49552
  1654.                 DC.W    28696,00000,00000,00000,00000,00000,00000,00040
  1655.                 DC.W    40960,08972,26160,49536,28696,00198,01100,58145
  1656.                 DC.W    10243,47104,00000,00040,40960,08972,26160,49536
  1657.                 DC.W    38936,00265,01106,38049,10244,04096,00000,00040
  1658.                 DC.W    40960,16268,26160,49544,38936,00454,01362,58529
  1659.                 DC.W    10243,04096,00000,00040,40960,08588,26160,49545
  1660.                 DC.W    03096,00297,01746,42913,10240,36864,00000,00040
  1661.                 DC.W    40960,08588,50784,49561,03096,00198,01100,38076
  1662.                 DC.W    52999,04096,00000,00040,40960,29663,36801,58363
  1663.                 DC.W    40508,00000,00000,00000,00000,00000,00000,00040
  1664.                 DC.W    40960,00000,00000,00000,00000,00000,00000,00000
  1665.                 DC.W    00000,00000,00000,00040,40960,00000,00000,00000
  1666.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00040
  1667.                 DC.W    40960,00000,00000,00000,00000,00275,14536,39207
  1668.                 DC.W    12312,60942,12560,00040,40960,00000,00000,00000
  1669.                 DC.W    00000,00276,42285,42408,18469,01025,17200,00040
  1670.                 DC.W    40960,00000,00000,00000,00000,00340,47402,42347
  1671.                 DC.W    18469,01030,28944,00040,40960,00000,00000,16383
  1672.                 DC.W    65504,00439,43496,48425,30781,01032,18704,00040
  1673.                 DC.W    40960,00000,00000,08192,00032,00276,42280,42279
  1674.                 DC.W    18468,58383,13240,00040,40960,00151,00256,11832
  1675.                 DC.W    58272,00000,00000,00000,00000,00000,00000,00040
  1676.                 DC.W    40960,00144,33536,08517,05152,00000,00000,00000
  1677.                 DC.W    00000,00000,00000,00040,40960,00147,00256,08322
  1678.                 DC.W    02080,00000,00000,00000,00000,00000,00000,00040
  1679.                 DC.W    40960,00100,00256,08517,05152,00201,15288,51315
  1680.                 DC.W    00000,00000,00000,00040,40960,00103,37760,11832
  1681.                 DC.W    58272,00297,16677,10276,32768,00000,00000,00040
  1682.                 DC.W    40960,00000,00000,08192,00032,00297,12601,10276
  1683.                 DC.W    32768,00000,00000,00040,40960,00000,00000,16383
  1684.                 DC.W    65504,00489,02345,59431,32768,00000,00000,00040
  1685.                 DC.W    40960,00000,00000,00000,00000,00294,28965,12148
  1686.                 DC.W    32768,00000,00000,00040,40960,00000,00000,00000
  1687.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00040
  1688.                 DC.W    40960,00000,00000,00000,00000,00000,00000,00000
  1689.                 DC.W    00000,00000,00000,00040,40960,00000,00000,00000
  1690.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00040
  1691.                 DC.W    49151,65535,65535,65535,65535,65535,65535,65535
  1692.                 DC.W    65535,65535,65535,65512,40960,00000,00000,00000
  1693.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00040
  1694.                 DC.W    32767,65535,65535,65535,65535,65535,65535,65535
  1695.                 DC.W    65535,65535,65535,65520
  1696.  
  1697. Generate        DC.W    $00,$00,$59,$0D,$02
  1698.                 DC.L    Generatedat
  1699.                 DC.B    $03,$00
  1700.                 DC.L    $00
  1701. Generatedat     DC.W    00000,00000,00000,00000,00000,00128,00000,00000
  1702.                 DC.W    00000,00000,00000,00384,00000,00463,48379,51007
  1703.                 DC.W    31744,00384,00000,01023,65535,61439,65024,00384
  1704.                 DC.W    00000,02047,65535,65535,64512,00384,00000,01982
  1705.                 DC.W    32743,65502,61440,00384,00000,02047,32759,65502
  1706.                 DC.W    63488,00384,00000,02046,32743,65502,61440,00384
  1707.                 DC.W    00000,02047,65535,65502,64512,00384,00000,01023
  1708.                 DC.W    65535,65502,65024,00384,00000,00463,46843,28044
  1709.                 DC.W    31744,00384,00000,00000,00000,00000,00000,00384
  1710.                 DC.W    32767,65535,65535,65535,65535,65408
  1711.                 DC.W    65535,65535,65535,65535,65535,65280,49152,00000
  1712.                 DC.W    00000,00000,00000,00000,49152,00000,00000,00000
  1713.                 DC.W    00000,00000,49152,00463,48379,51007,31744,00000
  1714.                 DC.W    49152,00812,14019,28556,24576,00000,49152,00780
  1715.                 DC.W    14019,28044,24576,00000,49152,00782,14051,28044
  1716.                 DC.W    28672,00000,49152,00876,14019,53132,24576,00000
  1717.                 DC.W    49152,00876,14019,28044,24576,00000,49152,00463
  1718.                 DC.W    46843,28044,31744,00000,49152,00000,00000,00000
  1719.                 DC.W    00000,00000,49152,00000,00000,00000,00000,00000
  1720.                 DC.W    32768,00000,00000,00000,00000,00000
  1721.  
  1722. Buttonon        DC.W    $00,$00,$11,$09,$02
  1723.                 DC.L    Buttonondat
  1724.                 DC.B    $03,$00
  1725.                 DC.L    $00
  1726. Buttonondat     DC.W    16380,00000,24576,00000,51184,00000,53240,00000
  1727.                 DC.W    53240,00000,53240,00000,51184,00000,24576,00000
  1728.                 DC.W    08192,00000
  1729.                 DC.W    00002,00000,00003,00000,02033,32768,04089,32768
  1730.                 DC.W    04089,32768,04089,32768,02033,32768,00003,00000
  1731.                 DC.W    08190,00000
  1732.  
  1733. Buttonoff       DC.W    $00,$00,$11,$09,$02
  1734.                 DC.L    Buttonoffdat
  1735.                 DC.B    $03,$00
  1736.                 DC.L    $00
  1737. Buttonoffdat    DC.W    00002,00000,00003,00000,00001,32768,00001,32768
  1738.                 DC.W    00001,32768,00001,32768,00001,32768,00003,00000
  1739.                 DC.W    08190,00000
  1740.                 DC.W    16380,00000,24576,00000,49152,00000,49152,00000
  1741.                 DC.W    49152,00000,49152,00000,49152,00000,24576,00000
  1742.                 DC.W    08192,00000
  1743.  
  1744. FReq            DC.W    0,0,20,14,2
  1745.                 DC.L    FReqdat
  1746.                 DC.B    3,0
  1747.                 DC.L    0
  1748. FReqdat         DC.W    00000,04096,00000,12288,00060,12288,00066,12288
  1749.                 DC.W    03969,12288,04033,12288,03135,12288,03073,12288
  1750.                 DC.W    03073,12288,03073,12288,04095,12288,00000,12288
  1751.                 DC.W    00000,12288,32767,61440
  1752.                 DC.W    65535,57344,49152,00000,49152,00000,49152,00000
  1753.                 DC.W    49152,00000,49152,00000,49152,00000,49152,00000
  1754.                 DC.W    49152,00000,49152,00000,49152,00000,49152,00000
  1755.                 DC.W    49152,00000,32768,00000
  1756.  
  1757. File            DC.W    -$07,-$03,$72,$0E,$02
  1758.                 DC.L    Filedat
  1759.                 DC.B    $03,$00
  1760.                 DC.L    $00
  1761. Filedat         DC.W    00000,00000,00000,00000,00000,00000,00000,00000
  1762.                 DC.W    32767,65535,65535,65535,65535,65535,65535,16384
  1763.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1764.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1765.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1766.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1767.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1768.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1769.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1770.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1771.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1772.                 DC.W    16384,00000,00000,00000,00000,00000,00000,16384
  1773.                 DC.W    00000,00000,00000,00000,00000,00000,00000,16384
  1774.                 DC.W    65535,65535,65535,65535,65535,65535,65535,49152
  1775.                 DC.W    65535,65535,65535,65535,65535,65535,65535,32768
  1776.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1777.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1778.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1779.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1780.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1781.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1782.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1783.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1784.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1785.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1786.                 DC.W    32768,00000,00000,00000,00000,00000,00000,32768
  1787.                 DC.W    65535,65535,65535,65535,65535,65535,65535,32768
  1788.                 DC.W    00000,00000,00000,00000,00000,00000,00000,00000
  1789.  
  1790.                 End     ; Adios Amigas
  1791.                 
  1792.  
  1793.  
  1794.  
  1795.